package com.utils;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;

/**
 * @Auther: ChenJinEn
 * @Date: 2020/8/1 15:59
 * @Description: //TODO
 */
public class MybatiseUtil {
    private static SqlSessionFactory sqlSessionFactory;
    static {
        InputStream inputStream = MybatiseUtil.class.getClassLoader().getResourceAsStream("mybatis-config.xml");
        SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
        sqlSessionFactory = builder.build(inputStream);
    }

    public static SqlSession getSqlSession(){
        return sqlSessionFactory.openSession();
    }
}
